'use client'

import { useState, useEffect } from 'react'
// import { Button, Card, Progress, message } from '@/components/ui'

// 定义角色属性接口
interface Character {
  age: number
  health: number
  happiness: number
  wealth: number
  intelligence: number
}

export default function Game() {
  // 初始化角色状态
  const [character, setCharacter] = useState<Character>({
    age: 0,
    health: 100,
    happiness: 100,
    wealth: 0,
    intelligence: 50
  })

  // 游戏是否结束
  const [gameOver, setGameOver] = useState(false)

  // 处理年龄增长
  const handleAging = () => {
    if (gameOver) return

    setCharacter(prev => {
      const newAge = prev.age + 1
      const newHealth = Math.max(0, prev.health - Math.random() * 5)
      
      // 检查游戏是否结束
      if (newHealth <= 0 || newAge >= 100) {
        setGameOver(true)
        
        return prev
      }

      return {
        ...prev,
        age: newAge,
        health: newHealth
      }
    })
  }

  // 处理学习
  const handleStudy = () => {
    if (gameOver) return
    
    setCharacter(prev => ({
      ...prev,
      intelligence: Math.min(100, prev.intelligence + 5),
      happiness: Math.max(0, prev.happiness - 3)
    }))
  }

  // 处理工作
  const handleWork = () => {
    if (gameOver) return
    
    setCharacter(prev => ({
      ...prev,
      wealth: prev.wealth + (prev.intelligence * 0.5),
      health: Math.max(0, prev.health - 2),
      happiness: Math.max(0, prev.happiness - 2)
    }))
  }

  // 处理休息
  const handleRest = () => {
    if (gameOver) return
    
    setCharacter(prev => ({
      ...prev,
      health: Math.min(100, prev.health + 10),
      happiness: Math.min(100, prev.happiness + 10)
    }))
  }

  // 重新开始游戏
  const handleRestart = () => {
    setCharacter({
      age: 0,
      health: 100,
      happiness: 100,
      wealth: 0,
      intelligence: 50
    })
    setGameOver(false)
  }

  return (
    <></>
    // <div className={styles.container}>
    //   <h1>人生模拟器</h1>
      
    //   <Card title="角色状态" className={styles.statusCard}>
    //     <p>年龄: {character.age}</p>
    //     <div>健康:
    //       <Progress percent={character.health} status={character.health < 20 ? 'exception' : undefined} />
    //     </div>
    //     <div>快乐:
    //       <Progress percent={character.happiness} status={character.happiness < 20 ? 'exception' : undefined} />
    //     </div>
    //     <div>财富: ¥{character.wealth.toFixed(0)}</div>
    //     <div>智力:
    //       <Progress percent={character.intelligence} />
    //     </div>
    //   </Card>

    //   <div className={styles.actions}>
    //     <Button onClick={handleAging} disabled={gameOver}>变老</Button>
    //     <Button onClick={handleStudy} disabled={gameOver}>学习</Button>
    //     <Button onClick={handleWork} disabled={gameOver}>工作</Button>
    //     <Button onClick={handleRest} disabled={gameOver}>休息</Button>
    //     {gameOver && <Button type="primary" onClick={handleRestart}>重新开始</Button>}
    //   </div>
    // </div>
  )
}
